/*
* 该文件专门为Count组件生成action对象
* 生成  action  {type:xx, data}
* */
import { INCREMENT, DECREMENT } from "./conatant";

// 同步action就是指action的值为object一般对象
export const createIncrementAction = data => ({type: INCREMENT, data});

export const createDecrementAction = (data) => ({type: DECREMENT, data});

// 所谓的异步action就是指 action的值为函数,  异步action中一般都会调用同步的action, 异步action不是必须要用的
export  const createIncrementAsyncAction = (data, time) => {
  return (dispatch) => {
    setTimeout(() => {
      dispatch(createIncrementAction(data))
    }, time)
  }
}

